﻿@using System.Web.Mvc.Html
@using System.Web.UI.WebControls
@model KRM.Core.tblUser
@{
    ViewBag.Title = Model.UserID > 0 ? "Update user: " + Model.Username : "Add new user";
    Layout = "~/Views/Shared/_PopupLayout.cshtml";

    
}
<!-- User-->
<script src="~/js/User.js"></script>
<div style="padding: 10px">
    @Html.Partial("Partial/_MessageResult")
    <form class="margin0 " id="frm-adduser" action="/users/Adduser" method="POST">
        <input type="hidden" name="userid" value="@Model.UserID"/>
        <input type="hidden" name="HRPersonalId" value="@Model.HRPersonalId"/>
        <input type="hidden" name="UserPassword" value="@Model.UserPassword"/>
        <fieldset>
            <legend></legend>
            <div class="row-fluid">
                <div class="span3">Name</div>
                <div class="span8">
                    <input type="text" value="@Model.Username" class="input-block-level" name="Username" required="required" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span3">User Name</div>
                <div class="span8">
                    <input type="text" class="input-block-level" value="@Model.UserLogin" name="UserLogin" required="required" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span3">Phone User Name</div>
                <div class="span8">
                    <input type="text" class="input-block-level" value="@Model.PhoneUserName" name="PhoneUserName" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span3">Department</div>
                <div class="span8">
                    @Html.DropDownList("departmentID", null, "No Department", new { @class = "input-block-level", required = "required" })
                </div>
            </div>
            <div class="row-fluid">
                <div class="span3">Default Task Type</div>
                <div class="span8">@Html.DropDownList("defaultTaskTypeID", null, "None", new { @class = "input-block-level" })</div>
            </div>
            <div class="row-fluid">
                <div class="span3">Email</div>
                <div class="span8">
                    <input type="text" class="input-block-level email" value= "@Model.MyEmail" name="myEmail" required="required" />



                </div>
            </div>
            <div class="row-fluid">
                <div class="span3">Pin Number</div>
                <div class="span8">
                    <input type="text" class="input-block-level" value="@Model.PINNumber" name="PINNumber" required="required" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span3">Default Assign Task Type </div>
                <div class="span8">@Html.DropDownList("defaultAssignTaskTypeID", null, "None", new { @class = "input-block-level" })</div>
            </div>
            <div class="row-fluid">
                <div class="span6" style="vertical-align: middle; display: inline-block">
                    <label>
                        @Html.CheckBox("Enabled", @Model.Enabled == true || @Model.Enabled == null ? true : false, new { @class = "cbcheck" })
                        Check to enable the user account
                    </label>
                </div>
                <div class="span6" style="vertical-align: middle">
                    <label>
                        @Html.CheckBox("PasswordNeverExpired", @Model.PasswordNeverExpired == true ? true : false, new { @class = "cbcheck" })
                        Password never expired
                    </label>

                </div>
            </div>


        </fieldset>
        <fieldset>
            <legend></legend>
            <div class="row-fluid" >
                <div class="span6">
                    <a data-toggle="modal"  onclick="@(Model.UserID>0?"$('#ManagerPicker').modal();":"alert('You need to save a user before you can manager Picker');" )" style="width: 85% !important" class="btn btn-primary btn-adduser" >Manager Picker</a>
                </div>
                <div class="span6">
                       <a data-toggle="modal"  onclick="@(Model.UserID>0?"$('#ManagerDriver').modal()":"alert('You need to save a user before you can manager Driver')" )" style="width: 85% !important" class="btn btn-primary btn-adduser" >Manager Driver</a>
                
                </div>
            </div>
            <div class="row-fluid">
                <div class="span6">
                    <input type="button" value="Manager Permissions" class="btn btn-adduser btn-primary" 
                        @* onclick="@(Model.UserID > 0 ? "PopupCenter('/Users/ManagerPermission/?userID=" + Model.UserID + "',1004,600)" : "alert('You need to save a user before you can assign permissions to them')")" />*@
                           onclick="@(Model.UserID > 0 ? "PopupCenter('/Users/ManagerPermission/?userID=" + Model.UserID + "',800,600)" : "alert('You need to save a user before you can assign permissions to them')")" />

                </div>
                <div class="span6">
                    <input type="button" value="Reset Password" class="btn btn-adduser btn-primary" 
                           onclick="@(Model.UserID > 0 ? "ResetPassword(" + Model.UserID + ",'" + Model.Username + "')" : "alert('You need to save a user before you can reset their password')")"  />
                </div>
            </div>
            <div class="row-fluid" >
                <div class="span6">
                    <input type="submit" value="Save" name="Save" class="btn btn-adduser btn-primary" />
                </div>
                <div class="span6">
                    <input type="button" value="Cancel" onclick="window.close();" class="btn btn-adduser btn-primary" />
                </div>
            </div>
        </fieldset>
    </form>
</div>

<div id="ManagerPicker" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="partGroup" aria-hidden="true">
    @Html.Action("ManagerPicker","Users")
</div>
<div id="ManagerDriver" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="partGroup" aria-hidden="true">
    @Html.Action("ManagerDriver","Users")
</div>
